## BTW

rm(list = ls())

library(tidyverse)
library(fixest)

## Get saved results
## Note that these results are produce by a separate script

res <- read_rds("data/Results_Main.rds") %>%
    filter(str_detect(unit, "Federal") & fe == "Year FE") %>%
    filter(str_detect(outcome, "polar_bund_diff|small_party")) %>%
    filter(!str_detect(outcome, "small_party2")) %>%
    filter(str_detect(term, "Decrease")) %>%
    filter(ss == "Combined") %>%
    mutate(outcome = dplyr::recode(outcome,
        `small_party_diff` = "Small party vote share",
        `polar_bund_diff` = "Polarization"
    )) %>%
    filter(!period_numeric == 3)


## Figure 4

pd <- position_dodge(0.4)

p1 <- res %>%
    ggplot(aes(period_numeric, estimate)) +
    geom_vline(xintercept = 0, linetype = "dotted") +
    geom_hline(yintercept = 0, linetype = "dotted") +
    geom_errorbar(aes(ymin = conf.low90, ymax = conf.high90),
        width = 0, position = pd, size = 1
    ) +
    geom_errorbar(aes(ymin = conf.low, ymax = conf.high),
        width = 0, position = pd, size = 0.5
    ) +
    geom_point(
        shape = 21, position = pd,
        fill = "white",
        size = 3
    ) +
    facet_wrap(~outcome, scales = "free", ncol = 4) +
    scale_x_continuous(breaks = -3:3) +
    theme_bw() +
    xlab("") +
    ylab("") +
    xlab("Elections before and after newspaper exit") +
    ylab("Effect of newspaper exit")
p1

